import modelEntity from "./modelEntity";
export default class RuleResultTemplate extends modelEntity {
  constructor(options) {
    super(options);
    this.Ref_RuleTemplate_Guid = options.Ref_RuleTemplate_Guid;
    this.Index = options.Index;
    this.Ref_Role_Guid = options.Ref_Role_Guid;
    this.NeedPrj = options.NeedPrj;
  }
  static newInstance() {
    return new RuleResultTemplate({
      Ref_RuleTemplate_Guid: null,
      Index: null,
      Ref_Role_Guid: null,
      NeedPrj: null,
    })
  }
  static loadList() {
    return new Promise((resolve, reject) => {
      getApp().globalData.api.http_get(`${getApp().globalData.baseUrl}/api/sys/ruleresulttemplate`)
        .then(
          res => {
            console.log(res);
            let list = [];
            res.forEach(x => {
              list.push(new RuleResultTemplate(x));
            });
            resolve(list);
          }
        )
    })
  }
  create() {
    return new Promise((resolve, reject) => {
      window.api.http_post("/api/sys/ruleresulttemplate", this)
        .then(
          res => {
            let model = new RuleResultTemplate(res);
            resolve(model);
          }
        )
    })
  }
  delete() {
    return new Promise((resolve, reject) => {
      window.api.http_delete("/api/sys/ruleresulttemplate", this)
        .then(
          res => {
            resolve(res);
          }
        )
    })
  }
  modify() {
    return new Promise((resolve, reject) => {
      window.api.http_put("/api/sys/ruleresulttemplate", this)
        .then(
          res => {
            let model = new RuleResultTemplate(res);
            resolve(model);
          }
        )
    })
  }
}
